package 笔试.百度;

import java.util.HashSet;
import java.util.Scanner;

/**
 * @author:谢君臣
 * @Date:2021/9/7-18:40
 * @version:1.0
 * @function:
 */
public class Main01 {
    static long res = 0;
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int k = scanner.nextInt();
        scanner.nextLine();
        String str = scanner.nextLine();
        if (help(str, k)) res++;
        dfs(str.toCharArray(), 0, "", k);
        System.out.println(res);
    }
    public static void dfs(char[] str, int i, String tmp, int k){
        if (i == str.length) {
            if (help(tmp, k)) {
                System.out.println(tmp);
                res++;
            }
            return;
        }
        dfs(str, i+1, tmp, k);
        dfs(str, i+1, tmp+str[i], k);
    }
    public static boolean help(String str, int k){
        HashSet<Character> set = new HashSet<>();
        for (int i = 0; i < str.length(); i++){
            set.add(str.charAt(i));
        }
        return set.size()==k;
    }
}
